import Vue from 'vue'
import Router from 'vue-router'
import routes from './views'
Vue.use(Router);

export default new Router({
  beforeEach(to, from, next) {
    Vue.prototype.$message.closeAll();
    const CancelToken = Vue.axios.CancelToken;
    if (window.store) {
      window.store.state.source.cancel && window.store.state.source.cancel();
      window.store.commit('setSource', CancelToken.source())
    }
    next()
  },
  routes: routes
})
